using System;
using System.Data;
using System.Collections;
using System.Runtime.Serialization;
using Widgetsphere.Core.Util;
using Widgetsphere.Core.DataAccess;
using System.Collections.Generic;
using ACME.Northwind.Business.Objects;
using ACME.Northwind.Domain.Objects;

namespace ACME.Northwind.Business.SelectCommands
{
	#region CustomerSelectByCity

	/// <summary>
	/// Select command used to perform selects by field 'City'
	/// </summary>
	[Serializable]
	public partial class CustomerSelectByCity : SelectCommand, ISerializable
	{
		private string mCity; 
		private CustomerPaging _paging = null;
		private int mCount = -1;

		#region Serialization

		/// <summary>
		/// Serialization constructor
		/// </summary>
		protected CustomerSelectByCity(SerializationInfo info, StreamingContext context): base(info,context)
		{
			mCity = info.GetString("mCity");
			_paging = (CustomerPaging)info.GetValue("paging", typeof(CustomerPaging));
		}

		/// <summary>
		/// Method used internally for serialization
		/// </summary>
		public override void GetObjectData(SerializationInfo info, StreamingContext context)
		{
			base.GetObjectData(info, context);
			info.AddValue("mCity", mCity);
			info.AddValue("paging", _paging);
		}

		#endregion 

		/// <summary>
		/// The total number of rows returned. This is populated after the database is queried.
		/// </summary>
		public int Count
		{
		  get { return mCount; }
		}

		/// <summary>
		/// Select command that allows for the selection by field of database rows
		/// </summary>
		public CustomerSelectByCity(string city)
		{
			mCity = city; 
		}

		/// <summary>
		/// Select command that allows for the paged selection by field of database rows
		/// </summary>
		public CustomerSelectByCity(string city, CustomerPaging paging)
				:this(city)
		{
			_paging = paging; 
		}

		/// <summary>
		/// Creates a persistable domainCollection
		/// </summary>
		public override IDomainCollection CreateDomainCollection()
		{
			DomainCustomerCollection colDomain = new DomainCustomerCollection();
			return colDomain;
		}

		/// <summary>
		/// The stored procedure name to select values to populate a 'Customer' collection in a paged fashion
		/// </summary>
		public override string StoredProcedureName
		{
			get { return "gen_CustomerSelectByCity"; }
		}

		/// <summary>
		/// Initializes the parameters for this select command
		/// </summary>
		protected override void SetupParameterValues(SubDomainBase subDomain)
		{
			if (_paging != null)
			{
				if (_paging.OrderByList.Count != 1)
					throw new Exception("The select operation supports exactly one OrderBy field.");

				ParameterValues.Add("@paging_Ascending", _paging.OrderByList[0].Ascending);
				ParameterValues.Add("@paging_OrderByColumn", CustomerCollection.GetDatabaseFieldName(_paging.OrderByList[0].Field));
				ParameterValues.Add("@paging_PageIndex", _paging.PageIndex);
				ParameterValues.Add("@paging_RecordsperPage", _paging.RecordsperPage);
			}

		}

		/// <summary>
		/// Execute this select command on the database
		/// </summary>
		public override IDomainCollection Execute(SubDomainBase subDomain)
		{
			this.SetupParameterValues(subDomain);
			PersistableDomainCollectionBase returnTable = (PersistableDomainCollectionBase)this.CreateDomainCollection();

			IDbCommand fillCommand = PersistableDomainCollectionBase.GetFillCommand(this.ConnectionString, this.StoredProcedureName);
			fillCommand.CommandTimeout = this.DefaultTimeOut;
			PersistableDomainCollectionBase.SetParameterValue(fillCommand, "@City", mCity);

			//Add the parameters
			foreach (string key in ParameterValues.Keys)
			{
				PersistableDomainCollectionBase.SetParameterValue(fillCommand, key, ParameterValues[key]);
			}

			IDbDataParameter paramCount = null;
			paramCount = PersistableDomainCollectionBase.GetOutputParameter(fillCommand, "@paging_Count");

			returnTable.FillDataTable(this.ConnectionString, fillCommand);
			if (_paging != null)
			{
				if (paramCount.Value != System.DBNull.Value) mCount = (int)paramCount.Value;
				else mCount = 0;
			}

			return returnTable;
		}

		#region SelectCommand Abstact Override

		/// <summary>
		/// The connection string used to connect to the database
		/// </summary>
		public override string ConnectionString
		{
			get { return ConfigurationValues.GetInstance().ConnectionString; }
		}

		/// <summary>
		/// Determines the default time out
		/// </summary>
		public override int DefaultTimeOut
		{
			get {	return ConfigurationValues.GetInstance().DefaultTimeOut; }
		}

		#endregion

	}

	#endregion

	#region CustomerSelectAll

	/// <summary>
	/// The select command used to select all rows from the 'Customer' table
	/// </summary>
	[Serializable]
	public partial class CustomerSelectAll : SelectCommand, ISerializable
	{

		#region Serialization

		/// <summary>
		/// Serialization constructor
		/// </summary>
		protected CustomerSelectAll(SerializationInfo info, StreamingContext context): base(info,context)
		{
		}

		/// <summary>
		/// Method used internally for serialization
		/// </summary>
		public override void GetObjectData(SerializationInfo info, StreamingContext context)
		{
			base.GetObjectData(info, context);
		}

		#endregion 

		/// <summary>
		/// Default constructor
		/// </summary>
		public CustomerSelectAll()
		{
		}

		/// <summary>
		/// Creates a persistable domainCollection
		/// </summary>
		public override IDomainCollection CreateDomainCollection()
		{
			DomainCustomerCollection colDomain = new DomainCustomerCollection();
			return colDomain;
		}

		/// <summary>
		/// The stored procedure name to select values to populate a 'Customer' collection
		/// </summary>
		public override string StoredProcedureName
		{
			get { return "gen_CustomerSelect"; }
		}

		/// <summary>
		/// Initializes the parameters for this select command
		/// </summary>
		protected override void SetupParameterValues(SubDomainBase subDomain)
		{
		}

		#region SelectCommand Abstact Override

		/// <summary>
		/// The connection string used to connect to the database
		/// </summary>
		public override string ConnectionString
		{
			get { return ConfigurationValues.GetInstance().ConnectionString; }
		}

		/// <summary>
		/// Determines the default time out
		/// </summary>
		public override int DefaultTimeOut
		{
			get {	return ConfigurationValues.GetInstance().DefaultTimeOut; }
		}

		#endregion

	}

	#endregion

	#region CustomerPagedSelect

	/// <summary>
	/// Select command used to perform paged selects from the 'Customer' table
	/// </summary>
	[Serializable]
	public partial class CustomerPagedSelect : SelectCommand, ISerializable
	{
		private int mPage; 
		private int mPageSize;
		private string mOrderByColumn;
		private bool mAscending;
		private string mFilter;
		private int mCount = -1;

		#region Serialization

		/// <summary>
		/// Serialization constructor
		/// </summary>
		protected CustomerPagedSelect(SerializationInfo info, StreamingContext context): base(info,context)
		{
			mPage = info.GetInt32("mPage");
			mPageSize = info.GetInt32("mPageSize");
			mOrderByColumn = info.GetString("mOrderByColumn");
			mAscending = info.GetBoolean("mAscending");
			mFilter = info.GetString("mFilter");
			mCount = info.GetInt32("mCount");
		}

		/// <summary>
		/// Method used internally for serialization
		/// </summary>
		public override void GetObjectData(SerializationInfo info, StreamingContext context)
		{
			base.GetObjectData(info, context);
			info.AddValue("mPage", mPage);
			info.AddValue("mPageSize", mPageSize);
			info.AddValue("mOrderByColumn", mOrderByColumn);
			info.AddValue("mAscending", mAscending);
			info.AddValue("mFilter", mFilter);
			info.AddValue("mCount", mCount);
		}

		#endregion 

		/// <summary>
		/// Paging select command that allows for the selective page-based selection of database rows
		/// </summary>
		public CustomerPagedSelect(int page, int pageSize, string orderByColumn, bool ascending, string filter)
		{
			mPage = page; 
			mPageSize = pageSize;
			mOrderByColumn = orderByColumn;
			mAscending = ascending;
			mFilter = filter;
		}

		/// <summary>
		/// The total number of rows returned. This is populated after the database is queried.
		/// </summary>
		public int Count
		{
		  get { return mCount; }
		}

		/// <summary>
		/// Creates a persistable domainCollection
		/// </summary>
		public override IDomainCollection CreateDomainCollection()
		{
			DomainCustomerCollection colDomain = new DomainCustomerCollection();
			return colDomain;
		}

		/// <summary>
		/// The stored procedure name to select values to populate a 'Customer' collection in a paged fashion
		/// </summary>
		public override string StoredProcedureName
		{
			get { return "gen_CustomerPagingSelect"; }
		}

		/// <summary>
		/// Initializes the parameters for this select command
		/// </summary>
		protected override void SetupParameterValues(SubDomainBase subDomain)
		{
		}

		/// <summary>
		/// Execute this select command on the database
		/// </summary>
		public override IDomainCollection Execute(SubDomainBase subDomain)
		{
			this.SetupParameterValues(subDomain);
			PersistableDomainCollectionBase returnTable = (PersistableDomainCollectionBase)this.CreateDomainCollection();

			IDbCommand fillCommand = PersistableDomainCollectionBase.GetFillCommand(this.ConnectionString, this.StoredProcedureName);
			fillCommand.CommandTimeout = this.DefaultTimeOut;
			PersistableDomainCollectionBase.SetParameterValue(fillCommand, "@page", mPage);
			PersistableDomainCollectionBase.SetParameterValue(fillCommand, "@pageSize", mPageSize);
			PersistableDomainCollectionBase.SetParameterValue(fillCommand, "@orderByColumn", mOrderByColumn);
			PersistableDomainCollectionBase.SetParameterValue(fillCommand, "@ascending", mAscending);
			PersistableDomainCollectionBase.SetParameterValue(fillCommand, "@filter", mFilter);
			IDbDataParameter paramCount = PersistableDomainCollectionBase.GetOutputParameter(fillCommand, "@count");
			returnTable.FillDataTable(this.ConnectionString, fillCommand);
			if(paramCount.Value != System.DBNull.Value)
			{
				mCount = (int)paramCount.Value;
			}
			else
			{
				mCount = 0;
			}
			return returnTable;
		}

		#region SelectCommand Abstact Override

		/// <summary>
		/// The connection string used to connect to the database
		/// </summary>
		public override string ConnectionString
		{
			get { return ConfigurationValues.GetInstance().ConnectionString; }
		}

		/// <summary>
		/// Determines the default time out
		/// </summary>
		public override int DefaultTimeOut
		{
			get {	return ConfigurationValues.GetInstance().DefaultTimeOut; }
		}

		#endregion

	}

	#endregion

	#region CustomerSelectByPks

	/// <summary>
	/// A select command that selects objects by primary key
	/// </summary>
	[Serializable]
	public partial class CustomerSelectByPks : SelectCommand, ISerializable
	{
		private List<CustomerPrimaryKey> mPrimaryKeys = null;

		#region Serialization

		/// <summary>
		/// Serialization constructor
		/// </summary>
		protected CustomerSelectByPks(SerializationInfo info, StreamingContext context): base(info,context)
		{
			mPrimaryKeys = new List<CustomerPrimaryKey>();
			mPrimaryKeys.AddRange((CustomerPrimaryKey[])info.GetValue("mPrimaryKeys", typeof(CustomerPrimaryKey[])));
		}

		/// <summary>
		/// Method used internally for serialization
		/// </summary>
		public override void GetObjectData(SerializationInfo info, StreamingContext context)
		{
			base.GetObjectData(info, context);
			info.AddValue("mPrimaryKeys", mPrimaryKeys.ToArray());
		}

		#endregion 

		/// <summary>
		/// Select objects by primary key
		/// </summary>
		public CustomerSelectByPks(string customerid)
		{
			mPrimaryKeys = new List<CustomerPrimaryKey>();
			mPrimaryKeys.Add(new CustomerPrimaryKey(customerid));

		}

		/// <summary>
		/// Select objects by a primary key
		/// </summary>
		public CustomerSelectByPks(CustomerPrimaryKey primaryKey)
		{
			mPrimaryKeys = new List<CustomerPrimaryKey>();
			mPrimaryKeys.Add(primaryKey);
		}

		/// <summary>
		/// Select objects by a list of primary keys
		/// </summary>
		public CustomerSelectByPks(IEnumerable<CustomerPrimaryKey> primaryKeys)
		{
			mPrimaryKeys = new List<CustomerPrimaryKey>();
			mPrimaryKeys.AddRange(primaryKeys);
		}

		/// <summary>
		/// Creates a persistable domainCollection
		/// </summary>
		public override IDomainCollection CreateDomainCollection()
		{
			DomainCustomerCollection colDomain = new DomainCustomerCollection();
			return colDomain;
		}

		/// <summary>
		/// The stored procedure name to select values by primary key to populate a 'Customer' collection
		/// </summary>
		public override string StoredProcedureName
		{
			get
			{
				if (mPrimaryKeys.Count == 1) return "gen_CustomerSelectByCustomerSinglePk";
				else return "gen_CustomerSelectByCustomerPks";
			}
		}

		/// <summary>
		/// Initializes the parameters for this select command
		/// </summary>
		protected override void SetupParameterValues(SubDomainBase subDomain)
		{
			if (mPrimaryKeys.Count == 1)
			{
				CustomerPrimaryKey key = ((CustomerPrimaryKey)mPrimaryKeys[0]);
				ParameterValues.Add("@CustomerID", key.CustomerId);
			}
			else
				ParameterValues.Add("@xml", DomainCustomerCollection.GetPrimaryKeyXml(mPrimaryKeys));
		}

		#region SelectCommand Abstact Override

		/// <summary>
		/// The connection string used to connect to the database
		/// </summary>
		public override string ConnectionString
		{
			get { return ConfigurationValues.GetInstance().ConnectionString; }
		}

		/// <summary>
		/// Determines the default time out
		/// </summary>
		public override int DefaultTimeOut
		{
			get {	return ConfigurationValues.GetInstance().DefaultTimeOut; }
		}

		#endregion

	}

	#endregion

	#region CustomerSelectByCreatedDateRange

	/// <summary>
	/// Select objects by their created date.
	/// </summary>
	[Serializable]
	public partial class CustomerSelectByCreatedDateRange : SelectCommand, ISerializable
	{
		private DateTime? mStartDate;
		private DateTime? mEndDate;

		#region Serialization

		/// <summary>
		/// Select objects by their created date.
		/// </summary>
		protected CustomerSelectByCreatedDateRange(SerializationInfo info, StreamingContext context): base(info,context)
		{
			mStartDate = info.GetDateTime("mStartDate");
			mEndDate = info.GetDateTime("mEndDate");
		}

		/// <summary>
		/// Method used internally for serialization
		/// </summary>
		public override void GetObjectData(SerializationInfo info, StreamingContext context)
		{
			base.GetObjectData(info, context);
			info.AddValue("mStartDate", mStartDate);
			info.AddValue("mEndDate", mEndDate);
		}

		#endregion 

		/// <summary>
		/// Select objects by their created date.
		/// </summary>
		public CustomerSelectByCreatedDateRange(DateTime? startDate, DateTime? endDate)
		{
			mStartDate = startDate;
			mEndDate = endDate;
		}

		/// <summary>
		/// Creates a persistable domainCollection
		/// </summary>
		public override IDomainCollection CreateDomainCollection()
		{
			DomainCustomerCollection colDomain = new DomainCustomerCollection();
			return colDomain;
		}

		/// <summary>
		/// The stored procedure name to select values to populate a 'Customer' collection in a paged fashion
		/// </summary>
		public override string StoredProcedureName
		{
			get { return "gen_CustomerSelectByCreatedDateRange"; }
		}

		/// <summary>
		/// Initializes the parameters for this select command
		/// </summary>
		protected override void SetupParameterValues(SubDomainBase subDomain)
		{
			ParameterValues.Add("@start_date", mStartDate);
			ParameterValues.Add("@end_date", mEndDate);
		}

		/// <summary>
		/// Execute this select command on the database
		/// </summary>
		public override IDomainCollection Execute(SubDomainBase subDomain)
		{
			this.SetupParameterValues(subDomain);
			PersistableDomainCollectionBase returnTable = (PersistableDomainCollectionBase)this.CreateDomainCollection();

			IDbCommand fillCommand = PersistableDomainCollectionBase.GetFillCommand(this.ConnectionString, this.StoredProcedureName);
			fillCommand.CommandTimeout = this.DefaultTimeOut;
			PersistableDomainCollectionBase.SetParameterValue(fillCommand, "@start_date", mStartDate);
			PersistableDomainCollectionBase.SetParameterValue(fillCommand, "@end_date", mEndDate);
			returnTable.FillDataTable(this.ConnectionString, fillCommand);
			return returnTable;
		}

		#region SelectCommand Abstact Override

		/// <summary>
		/// The connection string used to connect to the database
		/// </summary>
		public override string ConnectionString
		{
			get { return ConfigurationValues.GetInstance().ConnectionString; }
		}

		/// <summary>
		/// Determines the default time out
		/// </summary>
		public override int DefaultTimeOut
		{
			get {	return ConfigurationValues.GetInstance().DefaultTimeOut; }
		}

		#endregion

	}

	#endregion

	#region CustomerSelectByModifiedDateRange

	/// <summary>
	/// Select objects by their modified date.
	/// </summary>
	[Serializable]
	public partial class CustomerSelectByModifiedDateRange : SelectCommand, ISerializable
	{
		private DateTime? mStartDate;
		private DateTime? mEndDate;

		#region Serialization

		/// <summary>
		/// Select objects by their modified date.
		/// </summary>
		protected CustomerSelectByModifiedDateRange(SerializationInfo info, StreamingContext context): base(info,context)
		{
			mStartDate = info.GetDateTime("mStartDate");
			mEndDate = info.GetDateTime("mEndDate");
		}

		/// <summary>
		/// Method used internally for serialization
		/// </summary>
		public override void GetObjectData(SerializationInfo info, StreamingContext context)
		{
			base.GetObjectData(info, context);
			info.AddValue("mStartDate", mStartDate);
			info.AddValue("mEndDate", mEndDate);
		}

		#endregion 

		/// <summary>
		/// Select objects by their modified date.
		/// </summary>
		public CustomerSelectByModifiedDateRange(DateTime? startDate, DateTime? endDate)
		{
			mStartDate = startDate;
			mEndDate = endDate;
		}

		/// <summary>
		/// Creates a persistable domainCollection
		/// </summary>
		public override IDomainCollection CreateDomainCollection()
		{
			DomainCustomerCollection colDomain = new DomainCustomerCollection();
			return colDomain;
		}

		/// <summary>
		/// The stored procedure name to select values to populate a 'Customer' collection in a paged fashion
		/// </summary>
		public override string StoredProcedureName
		{
			get { return "gen_CustomerSelectByModifiedDateRange"; }
		}

		/// <summary>
		/// Initializes the parameters for this select command
		/// </summary>
		protected override void SetupParameterValues(SubDomainBase subDomain)
		{
			ParameterValues.Add("@start_date", mStartDate);
			ParameterValues.Add("@end_date", mEndDate);
		}

		/// <summary>
		/// Execute this select command on the database
		/// </summary>
		public override IDomainCollection Execute(SubDomainBase subDomain)
		{
			this.SetupParameterValues(subDomain);
			PersistableDomainCollectionBase returnTable = (PersistableDomainCollectionBase)this.CreateDomainCollection();

			IDbCommand fillCommand = PersistableDomainCollectionBase.GetFillCommand(this.ConnectionString, this.StoredProcedureName);
			fillCommand.CommandTimeout = this.DefaultTimeOut;
			PersistableDomainCollectionBase.SetParameterValue(fillCommand, "@start_date", mStartDate);
			PersistableDomainCollectionBase.SetParameterValue(fillCommand, "@end_date", mEndDate);
			returnTable.FillDataTable(this.ConnectionString, fillCommand);
			return returnTable;
		}

		#region SelectCommand Abstact Override

		/// <summary>
		/// The connection string used to connect to the database
		/// </summary>
		public override string ConnectionString
		{
			get { return ConfigurationValues.GetInstance().ConnectionString; }
		}

		/// <summary>
		/// Determines the default time out
		/// </summary>
		public override int DefaultTimeOut
		{
			get {	return ConfigurationValues.GetInstance().DefaultTimeOut; }
		}

		#endregion

	}

	#endregion

	#region CustomerSelectBySearch
	/// <summary>
	/// The select command used to select all rows from the 'Customer' table
	/// </summary>
	[Serializable]
	public partial class CustomerSelectBySearch : SelectCommand, ISerializable
	{
		private CustomerSearch Customer;
		private CustomerPaging _paging = null;
		private int mCount = -1;

		#region Serialization

		/// <summary>
		/// Serialization constructor
		/// </summary>
		protected CustomerSelectBySearch(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
			Customer = (CustomerSearch)info.GetValue("Customer", typeof(CustomerSearch));
			_paging = (CustomerPaging)info.GetValue("paging", typeof(CustomerPaging));
		}

		/// <summary>
		/// Method used internally for serialization
		/// </summary>
		public override void GetObjectData(SerializationInfo info, StreamingContext context)
		{
			base.GetObjectData(info, context);
			info.AddValue("Customer", Customer);
			info.AddValue("paging", _paging);
		}

		#endregion 

		/// <summary>
		/// The total number of rows returned. This is populated after the database is queried.
		/// </summary>
		public int Count
		{
		  get { return mCount; }
		}

		/// <summary>
		/// Select of objects by the Customer search object
		/// </summary>
		public CustomerSelectBySearch(CustomerSearch searchObject)
		{
			Customer = searchObject;
		}

		/// <summary>
		/// Paged select of objects by the Customer search object
		/// </summary>
		public CustomerSelectBySearch(CustomerSearch searchObject, CustomerPaging paging)
		{
			Customer = searchObject;
			_paging = paging;
		}


		/// <summary>
		/// Creates a persistable domainCollection
		/// </summary>
		public override IDomainCollection CreateDomainCollection()
		{
			DomainCustomerCollection colDomain = new DomainCustomerCollection();
			return colDomain;
		}

		/// <summary>
		/// The stored procedure name to select values by primary key to populate a 'Customer' collection
		/// </summary>
		public override string StoredProcedureName
		{
			get
			{
				if (Customer.SearchType == SearchType.OR)
					return "gen_CustomerSelectBySearchOr";
				else
					return "gen_CustomerSelectBySearchAnd";
			}
		}

		/// <summary>
		/// Initializes the parameters for this select command
		/// </summary>
		protected override void SetupParameterValues(SubDomainBase subDomain)
		{
			if (_paging != null)
			{
				if (_paging.OrderByList.Count != 1)
					throw new Exception("The select operation supports exactly one OrderBy field.");

				ParameterValues.Add("@paging_Ascending", _paging.OrderByList[0].Ascending);
				ParameterValues.Add("@paging_OrderByColumn", CustomerCollection.GetDatabaseFieldName(_paging.OrderByList[0].Field));
				ParameterValues.Add("@paging_PageIndex", _paging.PageIndex);
				ParameterValues.Add("@paging_RecordsperPage", _paging.RecordsperPage);
			}

			if (Customer != null)
			{
				if (Customer.Address != null)
				{
					ParameterValues.Add("@Address", Customer.Address);
				}
				if (Customer.City != null)
				{
					ParameterValues.Add("@City", Customer.City);
				}
				if (Customer.CompanyName != null)
				{
					ParameterValues.Add("@CompanyName", Customer.CompanyName);
				}
				if (Customer.ContactName != null)
				{
					ParameterValues.Add("@ContactName", Customer.ContactName);
				}
				if (Customer.ContactTitle != null)
				{
					ParameterValues.Add("@ContactTitle", Customer.ContactTitle);
				}
				if (Customer.Country != null)
				{
					ParameterValues.Add("@Country", Customer.Country);
				}
				if (Customer.CustomerId != null)
				{
					ParameterValues.Add("@CustomerID", Customer.CustomerId);
				}
				if (Customer.Fax != null)
				{
					ParameterValues.Add("@Fax", Customer.Fax);
				}
				if (Customer.Phone != null)
				{
					ParameterValues.Add("@Phone", Customer.Phone);
				}
				if (Customer.PostalCode != null)
				{
					ParameterValues.Add("@PostalCode", Customer.PostalCode);
				}
				if (Customer.Region != null)
				{
					ParameterValues.Add("@Region", Customer.Region);
				}

			}
		}

		/// <summary>
		/// Execute this select command on the database
		/// </summary>
		public override IDomainCollection Execute(SubDomainBase subDomain)
		{
			this.SetupParameterValues(subDomain);
			PersistableDomainCollectionBase returnTable = (PersistableDomainCollectionBase)this.CreateDomainCollection();

			IDbCommand fillCommand = PersistableDomainCollectionBase.GetFillCommand(this.ConnectionString, this.StoredProcedureName);
			fillCommand.CommandTimeout = this.DefaultTimeOut;

			//Add the parameters
			foreach (string key in ParameterValues.Keys)
			{
				PersistableDomainCollectionBase.SetParameterValue(fillCommand, key, ParameterValues[key]);
			}

			IDbDataParameter paramCount = null;
			paramCount = PersistableDomainCollectionBase.GetOutputParameter(fillCommand, "@paging_Count");

			returnTable.FillDataTable(this.ConnectionString, fillCommand);

			if (_paging != null)
			{
				if (paramCount.Value != System.DBNull.Value) mCount = (int)paramCount.Value;
				else mCount = 0;
			}

			return returnTable;
		}

		#region SelectCommand Abstact Override

		/// <summary>
		/// The connection string used to connect to the database
		/// </summary>
		public override string ConnectionString
		{
			get { return ConfigurationValues.GetInstance().ConnectionString; }
		}

		/// <summary>
		/// Determines the default time out
		/// </summary>
		public override int DefaultTimeOut
		{
			get {	return ConfigurationValues.GetInstance().DefaultTimeOut; }
		}

		#endregion


	}

	#endregion
}
